<template>
  <div id="LangSelectBox">
    <el-dropdown
      trigger="click"
      class="international"
      @command="handleSetLanguage"
    >
      <span
        class="el-dropdown-link iconfont"
        :class="
          $store.state.app.language == 'zh'
            ? 'icon-yuyan'
            : 'icon-dingbudaohang-yingwen'
        "
      >
        <!-- {{$store.state.app.language == 'zh'?'中文':'English'}} -->
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="zh">中文</el-dropdown-item>
        <el-dropdown-item command="en">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  computed: {
    language() {
      return this.$store.getters.language;
    }
  },
  data() {
    return {};
  },
  mounted() {
    console.log(this.$store.getters);
  },
  methods: {
    handleSetLanguage(lang) {
      this.$i18n.locale = lang;
      this.$store.dispatch("setLanguage", lang);
      this.$message({
        message: "Switch Language Success",
        type: "success"
      });
    }
  }
};
</script>
<style lang="scss" scoped>
#LangSelectBox {
  padding: 0 10px;
}
.el-dropdown-link {
  color: #fff;
}
</style>
